package com.cty.service;

import com.cty.mappers.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {


    @Autowired
    private UserMapper userMapper;

    //声明式事务
    @Transactional
    public void delete() {
        int rows = userMapper.delete(2);
        System.out.println("rows" + rows);
        //int i = 1/0;//报了除零异常，数据库没有删除数据，声明式事务成立
    }
}
